package com.runlooker.runer.db;

public class RunerTableSql {
	public static final String ROSTER_ENTRY_TABLE = "roster_table"; // 联系人表
	public static final String PERSON_INFO_ENTRY_TABLE = "person_table"; // 用户信息表
	public static final String MESSAGE_ENTRY_TABLE = "message_table"; // 消息表
	public static final String PRESENCE_ENTRY_TABLE = "Presence_table"; // 出席信息记录表

	/**
	 * 
	 * 联系人状态表
	 * 
	 * @return
	 */
	public static String getRosterEntrySql() {
		StringBuffer sb_rosterEntry = new StringBuffer();
		sb_rosterEntry.append("CREATE TABLE " + ROSTER_ENTRY_TABLE + " (");
		sb_rosterEntry.append("account VARCHAR(50) PRIMARY KEY,");
		sb_rosterEntry.append("name VARCHAR(100) ,");
		// 对应Constant文件中的RosterPacket.ItemStatus: subscribe = 0,unsubscribe = 1;
		sb_rosterEntry.append("status INTEGER,");
		// 对应Constant文件中的RosterPacket.ItemType: both = 0,fromChat = 1,none
		// =2,remove
		// = 3,to = 4
		sb_rosterEntry.append("itemType INTEGER,");
		// 存储联系人所在的所有组（可能有多个组），组名由"[@group]"区分，如：成都群[@group]四川群[@group]北京群[@group]
		sb_rosterEntry.append("groupsName VARCHAR(1024)) ");
		return sb_rosterEntry.toString();
	}

	/**
	 * 个人详细信息
	 * 
	 * @return
	 */
	public static String getPersonInfoSql() {
		StringBuffer sb_info = new StringBuffer();
		sb_info.append("CREATE TABLE " + PERSON_INFO_ENTRY_TABLE + " (");
		sb_info.append("account VARCHAR(50) PRIMARY KEY,");// 帐号
		sb_info.append("fullName VARCHAR(50),");// 用户全称
		sb_info.append("nickName VARCHAR(50),");// 昵称
		sb_info.append("org VARCHAR(50),");// 组织名称
		sb_info.append("email VARCHAR(50),");// 邮件
		sb_info.append("phoneNum VARCHAR(50),");// 电话号码
		sb_info.append("ctry VARCHAR(100),");// 城市名
		sb_info.append("address VARCHAR(200),");// 地址
		sb_info.append("field  VARCHAR(100))");// 诗号
		return sb_info.toString();
	}

	/**
	 * 消息
	 * 
	 * @return
	 */
	public static String getMessageInfoSql() {
		StringBuffer sb_info = new StringBuffer();
		sb_info.append("CREATE TABLE " + MESSAGE_ENTRY_TABLE + " (");
		sb_info.append("id INTEGER PRIMARY KEY AUTOINCREMENT,");// 自增长ID
		sb_info.append("packetId VARCHAR(50),");// 消息流id
		sb_info.append("chatAccount VARCHAR(100) ,");// 聊天好友帐号
		sb_info.append("time VARCHAR(100) ,");// 收到、发送消息的时间
		sb_info.append("message VARCHAR(500) ,");// 发送出去的消息
		sb_info.append("isReaded INTEGER,");
		sb_info.append("isSended INTEGER,");
		sb_info.append("msgSourse INTEGER,");
		sb_info.append("msgType INTEGER,");
		sb_info.append("description TEXT,");
		sb_info.append("voicePlayStatus INTEGER,");
		sb_info.append("groupId INTEGER,");
		sb_info.append("chatType INTEGER,");
		sb_info.append("path TEXT,");
		sb_info.append("fileName VARCHAR(100))");// 发送出去的消息
		return sb_info.toString();
	}

	public static String getPresenceTableSql() {
		StringBuffer sb_info = new StringBuffer();
		sb_info.append("CREATE TABLE " + PRESENCE_ENTRY_TABLE + " (");
		sb_info.append("fromAccount VARCHAR(50),");
		sb_info.append("precenceType INTEGER )");
		return sb_info.toString();
	}

}
